package com.d3works.apps.hr.web;

import com.d3works.apps.hr.db.EmploymentAmendmentType;
import com.d3works.apps.hr.service.employee.EmploymentAmendmentTypeService;
import com.d3works.inject.Beans;
import com.d3works.rpc.ActionRequest;
import com.d3works.rpc.ActionResponse;

public class EmploymentAmendmentTypeController {

  public void setEmploymentContractSubTypeSetDomain(
      ActionRequest request, ActionResponse response) {
    EmploymentAmendmentType employmentAmendmentType =
        request.getContext().asType(EmploymentAmendmentType.class);

    String employmentContractSubTypeIds =
        Beans.get(EmploymentAmendmentTypeService.class)
            .getEmploymentContractSubTypeSetDomain(employmentAmendmentType);

    response.setAttr(
        "employmentContractSubTypeSet",
        "domain",
        "self.id IN (" + employmentContractSubTypeIds + ")");
  }

  public void setEmploymentContractSubTypeSet(ActionRequest request, ActionResponse response) {
    EmploymentAmendmentType employmentAmendmentType =
        request.getContext().asType(EmploymentAmendmentType.class);

    employmentAmendmentType =
        Beans.get(EmploymentAmendmentTypeService.class)
            .setEmploymentContractSubTypeSet(employmentAmendmentType);

    response.setValue(
        "employmentContractSubTypeSet", employmentAmendmentType.getEmploymentContractSubTypeSet());
  }
}
